import Vue from 'vue';
import Vuex from 'vuex';

Vue.use(Vuex);

export default new Vuex.Store({
	state() {
		return {
			myPosition: {
				lng: 116.39742,
				lat: 39.909,
			},
			myAddress: "",
			ipAddr: "http://mark.w1.luyouxia.net"
		};
	},
	getters: {
		getMyPosition(state) {
			return state.myPosition;
		},
		getMyAddress(state) {
			return state.myAddress;
		},
	},
	mutations: {

		updateMyPosition(state, newPosition) {
			state.myPosition = newPosition;
		},
		updateMyAddress(state, newAddress) {
			state.myAddress = newAddress;
		},
	},
	actions: {
		updateMyPosition({
			commit
		}, newPosition) {
			commit('updateMyPosition', newPosition);
		},
		updateMyAddress({
			commit
		}, newAddress) {
			commit('updateMyAddress', newAddress);
		},
	},
	modules: {},
});